package com.moon.test;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName: User
 * @Description: 用户类
 * @Author: 郭正洋
 * @Date: 2022/10/10 10:22
 * @Vsersion: 1.0.0
 **/
public class User {
	// 用户名
	public String userName;
	// 电影集
	public List<Movie> movieList = new ArrayList<>();

	public User(){}

	public User(String userName){
		this.userName = userName;
	}

	public User set(String movieName, int score) {
		this.movieList.add(new Movie(movieName, score));
		return this;
	}

	public Movie find(String movieName) {
		for (Movie movie : movieList) {
			if (movie.movieName.equals(userName)) {
				return movie;
			}
		}
		return null;
	}

	@Override
	public String toString() {
		return "User{" +
				"userName='" + userName + '\'' +
				'}';
	}
}
